#!/usr/bin/python
'''
Searchs a GFF and groups scaffolds with more than 1 type of repeat.
'''
import sys


# parameters.
gff_file = sys.argv[1]

# read in gff.
fin = open(gff_file, "rb")
lines = fin.readlines()
fin.close()

# parse out repeats.
bytypes = {}
for line in lines:
	# tokenize.
	if line[0] == "#": continue
	tmp = line.strip().split("\t")
	scafid = tmp[0]
	rtype = tmp[2]
	
	# save to dictionary.
	if scafid not in bytypes:
		bytypes[scafid] = {}
	bytypes[scafid][rtype] = True

# print out by group size.
for scafid in bytypes:
	if len(bytypes[scafid]) > 1:
		tmp = '\t'.join(bytypes[scafid].keys())
		print "%i\t%s\t%s" % (len(bytypes[scafid]), scafid, tmp)
